package com.wuchengdong.web.controller;

import com.wuchengdong.web.extend.utils.R;
import com.wuchengdong.web.pojo.Service;
import com.wuchengdong.web.service.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/service")
public class ServiceController {
    @Autowired
    private ServiceService serviceService;

    @RequestMapping
    public R<List<Service>> getAll() {
        return R.success(serviceService.list());
    }

    @RequestMapping("/saveOrUpdate")
    public R<String> saveOrUpdate(Service service) {
        return serviceService.saveOrUpdate(service) ? R.success("保存成功") : R.error("保存失败");
    }

    @RequestMapping("/deleteById")
    public R<String> deleteById(Service service) {
        return serviceService.removeById(service) ? R.success("删除成功") : R.error("删除失败");
    }
}
